home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / gnu-c / src / gcc-2.7.0-amiga / gcc.info-13 (.txt) < prev    next >
GNU Info File  |  1995-06-16  |  50KB  |  890 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.55 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 59 Temple Place - Suite 330
  5. Boston, MA 02111-1307 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995 Free Software
  7. Foundation, Inc.
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.    Permission is granted to copy and distribute modified versions of
  12. this manual under the conditions for verbatim copying, provided also
  13. that the sections entitled "GNU General Public License," "Funding for
  14. Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
  15. included exactly as in the original, and provided that the entire
  16. resulting derived work is distributed under the terms of a permission
  17. notice identical to this one.
  18.    Permission is granted to copy and distribute translations of this
  19. manual into another language, under the above conditions for modified
  20. versions, except that the sections entitled "GNU General Public
  21. License," "Funding for Free Software," and "Protect Your Freedom--Fight
  22. `Look And Feel'", and this permission notice, may be included in
  23. translations approved by the Free Software Foundation instead of in the
  24. original English.
  25. File: gcc.info,  Node: Interface,  Next: Passes,  Prev: Portability,  Up: Top
  26. Interfacing to GNU CC Output
  27. ****************************
  28.    GNU CC is normally configured to use the same function calling
  29. convention normally in use on the target system.  This is done with the
  30. machine-description macros described (*note Target Macros::.).
  31.    However, returning of structure and union values is done differently
  32. on some target machines.  As a result, functions compiled with PCC
  33. returning such types cannot be called from code compiled with GNU CC,
  34. and vice versa.  This does not cause trouble often because few Unix
  35. library routines return structures or unions.
  36.    GNU CC code returns structures and unions that are 1, 2, 4 or 8 bytes
  37. long in the same registers used for `int' or `double' return values.
  38. (GNU CC typically allocates variables of such types in registers also.)
  39. Structures and unions of other sizes are returned by storing them into
  40. an address passed by the caller (usually in a register).  The
  41. machine-description macros `STRUCT_VALUE' and `STRUCT_INCOMING_VALUE'
  42. tell GNU CC where to pass this address.
  43.    By contrast, PCC on most target machines returns structures and
  44. unions of any size by copying the data into an area of static storage,
  45. and then returning the address of that storage as if it were a pointer
  46. value.  The caller must copy the data from that memory area to the
  47. place where the value is wanted.  This is slower than the method used
  48. by GNU CC, and fails to be reentrant.
  49.    On some target machines, such as RISC machines and the 80386, the
  50. standard system convention is to pass to the subroutine the address of
  51. where to return the value.  On these machines, GNU CC has been
  52. configured to be compatible with the standard compiler, when this method
  53. is used.  It may not be compatible for structures of 1, 2, 4 or 8 bytes.
  54.    GNU CC uses the system's standard convention for passing arguments.
  55. On some machines, the first few arguments are passed in registers; in
  56. others, all are passed on the stack.  It would be possible to use
  57. registers for argument passing on any machine, and this would probably
  58. result in a significant speedup.  But the result would be complete
  59. incompatibility with code that follows the standard convention.  So this
  60. change is practical only if you are switching to GNU CC as the sole C
  61. compiler for the system.  We may implement register argument passing on
  62. certain machines once we have a complete GNU system so that we can
  63. compile the libraries with GNU CC.
  64.    On some machines (particularly the Sparc), certain types of arguments
  65. are passed "by invisible reference".  This means that the value is
  66. stored in memory, and the address of the memory location is passed to
  67. the subroutine.
  68.    If you use `longjmp', beware of automatic variables.  ANSI C says
  69. that automatic variables that are not declared `volatile' have undefined
  70. values after a `longjmp'.  And this is all GNU CC promises to do,
  71. because it is very difficult to restore register variables correctly,
  72. and one of GNU CC's features is that it can put variables in registers
  73. without your asking it to.
  74.    If you want a variable to be unaltered by `longjmp', and you don't
  75. want to write `volatile' because old C compilers don't accept it, just
  76. take the address of the variable.  If a variable's address is ever
  77. taken, even if just to compute it and ignore it, then the variable
  78. cannot go in a register:
  79.      {
  80.        int careful;
  81.        &careful;
  82.        ...
  83.      }
  84.    Code compiled with GNU CC may call certain library routines.  Most of
  85. them handle arithmetic for which there are no instructions.  This
  86. includes multiply and divide on some machines, and floating point
  87. operations on any machine for which floating point support is disabled
  88. with `-msoft-float'.  Some standard parts of the C library, such as
  89. `bcopy' or `memcpy', are also called automatically.  The usual function
  90. call interface is used for calling the library routines.
  91.    These library routines should be defined in the library `libgcc.a',
  92. which GNU CC automatically searches whenever it links a program.  On
  93. machines that have multiply and divide instructions, if hardware
  94. floating point is in use, normally `libgcc.a' is not needed, but it is
  95. searched just in case.
  96.    Each arithmetic function is defined in `libgcc1.c' to use the
  97. corresponding C arithmetic operator.  As long as the file is compiled
  98. with another C compiler, which supports all the C arithmetic operators,
  99. this file will work portably.  However, `libgcc1.c' does not work if
  100. compiled with GNU CC, because each arithmetic function would compile
  101. into a call to itself!
  102. File: gcc.info,  Node: Passes,  Next: RTL,  Prev: Interface,  Up: Top
  103. Passes and Files of the Compiler
  104. ********************************
  105.    The overall control structure of the compiler is in `toplev.c'.  This
  106. file is responsible for initialization, decoding arguments, opening and
  107. closing files, and sequencing the passes.
  108.    The parsing pass is invoked only once, to parse the entire input.
  109. The RTL intermediate code for a function is generated as the function
  110. is parsed, a statement at a time.  Each statement is read in as a
  111. syntax tree and then converted to RTL; then the storage for the tree
  112. for the statement is reclaimed.  Storage for types (and the expressions
  113. for their sizes), declarations, and a representation of the binding
  114. contours and how they nest, remain until the function is finished being
  115. compiled; these are all needed to output the debugging information.
  116.    Each time the parsing pass reads a complete function definition or
  117. top-level declaration, it calls either the function
  118. `rest_of_compilation', or the function `rest_of_decl_compilation' in
  119. `toplev.c', which are responsible for all further processing necessary,
  120. ending with output of the assembler language.  All other compiler
  121. passes run, in sequence, within `rest_of_compilation'.  When that
  122. function returns from compiling a function definition, the storage used
  123. for that function definition's compilation is entirely freed, unless it
  124. is an inline function (*note An Inline Function is As Fast As a Macro:
  125. Inline.).
  126.    Here is a list of all the passes of the compiler and their source
  127. files.  Also included is a description of where debugging dumps can be
  128. requested with `-d' options.
  129.    * Parsing.  This pass reads the entire text of a function definition,
  130.      constructing partial syntax trees.  This and RTL generation are no
  131.      longer truly separate passes (formerly they were), but it is
  132.      easier to think of them as separate.
  133.      The tree representation does not entirely follow C syntax, because
  134.      it is intended to support other languages as well.
  135.      Language-specific data type analysis is also done in this pass,
  136.      and every tree node that represents an expression has a data type
  137.      attached.  Variables are represented as declaration nodes.
  138.      Constant folding and some arithmetic simplifications are also done
  139.      during this pass.
  140.      The language-independent source files for parsing are
  141.      `stor-layout.c', `fold-const.c', and `tree.c'.  There are also
  142.      header files `tree.h' and `tree.def' which define the format of
  143.      the tree representation.
  144.      The source files to parse C are `c-parse.in', `c-decl.c',
  145.      `c-typeck.c', `c-aux-info.c', `c-convert.c', and `c-lang.c' along
  146.      with header files `c-lex.h', and `c-tree.h'.
  147.      The source files for parsing C++ are `cp-parse.y', `cp-class.c',
  148.      `cp-cvt.c', `cp-decl.c', `cp-decl2.c', `cp-dem.c', `cp-except.c',
  149.      `cp-expr.c', `cp-init.c', `cp-lex.c', `cp-method.c', `cp-ptree.c',
  150.      `cp-search.c', `cp-tree.c', `cp-type2.c', and `cp-typeck.c', along
  151.      with header files `cp-tree.def', `cp-tree.h', and `cp-decl.h'.
  152.      The special source files for parsing Objective C are
  153.      `objc-parse.y', `objc-actions.c', `objc-tree.def', and
  154.      `objc-actions.h'.  Certain C-specific files are used for this as
  155.      well.
  156.      The file `c-common.c' is also used for all of the above languages.
  157.    * RTL generation.  This is the conversion of syntax tree into RTL
  158.      code.  It is actually done statement-by-statement during parsing,
  159.      but for most purposes it can be thought of as a separate pass.
  160.      This is where the bulk of target-parameter-dependent code is found,
  161.      since often it is necessary for strategies to apply only when
  162.      certain standard kinds of instructions are available.  The purpose
  163.      of named instruction patterns is to provide this information to
  164.      the RTL generation pass.
  165.      Optimization is done in this pass for `if'-conditions that are
  166.      comparisons, boolean operations or conditional expressions.  Tail
  167.      recursion is detected at this time also.  Decisions are made about
  168.      how best to arrange loops and how to output `switch' statements.
  169.      The source files for RTL generation include `stmt.c', `calls.c',
  170.      `expr.c', `explow.c', `expmed.c', `function.c', `optabs.c' and
  171.      `emit-rtl.c'.  Also, the file `insn-emit.c', generated from the
  172.      machine description by the program `genemit', is used in this
  173.      pass.  The header file `expr.h' is used for communication within
  174.      this pass.
  175.      The header files `insn-flags.h' and `insn-codes.h', generated from
  176.      the machine description by the programs `genflags' and `gencodes',
  177.      tell this pass which standard names are available for use and
  178.      which patterns correspond to them.
  179.      Aside from debugging information output, none of the following
  180.      passes refers to the tree structure representation of the function
  181.      (only part of which is saved).
  182.      The decision of whether the function can and should be expanded
  183.      inline in its subsequent callers is made at the end of rtl
  184.      generation.  The function must meet certain criteria, currently
  185.      related to the size of the function and the types and number of
  186.      parameters it has.  Note that this function may contain loops,
  187.      recursive calls to itself (tail-recursive functions can be
  188.      inlined!), gotos, in short, all constructs supported by GNU CC.
  189.      The file `integrate.c' contains the code to save a function's rtl
  190.      for later inlining and to inline that rtl when the function is
  191.      called.  The header file `integrate.h' is also used for this
  192.      purpose.
  193.      The option `-dr' causes a debugging dump of the RTL code after
  194.      this pass.  This dump file's name is made by appending `.rtl' to
  195.      the input file name.
  196.    * Jump optimization.  This pass simplifies jumps to the following
  197.      instruction, jumps across jumps, and jumps to jumps.  It deletes
  198.      unreferenced labels and unreachable code, except that unreachable
  199.      code that contains a loop is not recognized as unreachable in this
  200.      pass.  (Such loops are deleted later in the basic block analysis.)
  201.      It also converts some code originally written with jumps into
  202.      sequences of instructions that directly set values from the
  203.      results of comparisons, if the machine has such instructions.
  204.      Jump optimization is performed two or three times.  The first time
  205.      is immediately following RTL generation.  The second time is after
  206.      CSE, but only if CSE says repeated jump optimization is needed.
  207.      The last time is right before the final pass.  That time,
  208.      cross-jumping and deletion of no-op move instructions are done
  209.      together with the optimizations described above.
  210.      The source file of this pass is `jump.c'.
  211.      The option `-dj' causes a debugging dump of the RTL code after
  212.      this pass is run for the first time.  This dump file's name is
  213.      made by appending `.jump' to the input file name.
  214.    * Register scan.  This pass finds the first and last use of each
  215.      register, as a guide for common subexpression elimination.  Its
  216.      source is in `regclass.c'.
  217.    * Jump threading.  This pass detects a condition jump that branches
  218.      to an identical or inverse test.  Such jumps can be `threaded'
  219.      through the second conditional test.  The source code for this
  220.      pass is in `jump.c'.  This optimization is only performed if
  221.      `-fthread-jumps' is enabled.
  222.    * Common subexpression elimination.  This pass also does constant
  223.      propagation.  Its source file is `cse.c'.  If constant propagation
  224.      causes conditional jumps to become unconditional or to become
  225.      no-ops, jump optimization is run again when CSE is finished.
  226.      The option `-ds' causes a debugging dump of the RTL code after
  227.      this pass.  This dump file's name is made by appending `.cse' to
  228.      the input file name.
  229.    * Loop optimization.  This pass moves constant expressions out of
  230.      loops, and optionally does strength-reduction and loop unrolling
  231.      as well.  Its source files are `loop.c' and `unroll.c', plus the
  232.      header `loop.h' used for communication between them.  Loop
  233.      unrolling uses some functions in `integrate.c' and the header
  234.      `integrate.h'.
  235.      The option `-dL' causes a debugging dump of the RTL code after
  236.      this pass.  This dump file's name is made by appending `.loop' to
  237.      the input file name.
  238.    * If `-frerun-cse-after-loop' was enabled, a second common
  239.      subexpression elimination pass is performed after the loop
  240.      optimization pass.  Jump threading is also done again at this time
  241.      if it was specified.
  242.      The option `-dt' causes a debugging dump of the RTL code after
  243.      this pass.  This dump file's name is made by appending `.cse2' to
  244.      the input file name.
  245.    * Stupid register allocation is performed at this point in a
  246.      nonoptimizing compilation.  It does a little data flow analysis as
  247.      well.  When stupid register allocation is in use, the next pass
  248.      executed is the reloading pass; the others in between are skipped.
  249.      The source file is `stupid.c'.
  250.    * Data flow analysis (`flow.c').  This pass divides the program into
  251.      basic blocks (and in the process deletes unreachable loops); then
  252.      it computes which pseudo-registers are live at each point in the
  253.      program, and makes the first instruction that uses a value point at
  254.      the instruction that computed the value.
  255.      This pass also deletes computations whose results are never used,
  256.      and combines memory references with add or subtract instructions
  257.      to make autoincrement or autodecrement addressing.
  258.      The option `-df' causes a debugging dump of the RTL code after
  259.      this pass.  This dump file's name is made by appending `.flow' to
  260.      the input file name.  If stupid register allocation is in use, this
  261.      dump file reflects the full results of such allocation.
  262.    * Instruction combination (`combine.c').  This pass attempts to
  263.      combine groups of two or three instructions that are related by
  264.      data flow into single instructions.  It combines the RTL
  265.      expressions for the instructions by substitution, simplifies the
  266.      result using algebra, and then attempts to match the result
  267.      against the machine description.
  268.      The option `-dc' causes a debugging dump of the RTL code after
  269.      this pass.  This dump file's name is made by appending `.combine'
  270.      to the input file name.
  271.    * Instruction scheduling (`sched.c').  This pass looks for
  272.      instructions whose output will not be available by the time that
  273.      it is used in subsequent instructions.  (Memory loads and floating
  274.      point instructions often have this behavior on RISC machines).  It
  275.      re-orders instructions within a basic block to try to separate the
  276.      definition and use of items that otherwise would cause pipeline
  277.      stalls.
  278.      Instruction scheduling is performed twice.  The first time is
  279.      immediately after instruction combination and the second is
  280.      immediately after reload.
  281.      The option `-dS' causes a debugging dump of the RTL code after this
  282.      pass is run for the first time.  The dump file's name is made by
  283.      appending `.sched' to the input file name.
  284.    * Register class preferencing.  The RTL code is scanned to find out
  285.      which register class is best for each pseudo register.  The source
  286.      file is `regclass.c'.
  287.    * Local register allocation (`local-alloc.c').  This pass allocates
  288.      hard registers to pseudo registers that are used only within one
  289.      basic block.  Because the basic block is linear, it can use fast
  290.      and powerful techniques to do a very good job.
  291.      The option `-dl' causes a debugging dump of the RTL code after
  292.      this pass.  This dump file's name is made by appending `.lreg' to
  293.      the input file name.
  294.    * Global register allocation (`global.c').  This pass allocates hard
  295.      registers for the remaining pseudo registers (those whose life
  296.      spans are not contained in one basic block).
  297.    * Reloading.  This pass renumbers pseudo registers with the hardware
  298.      registers numbers they were allocated.  Pseudo registers that did
  299.      not get hard registers are replaced with stack slots.  Then it
  300.      finds instructions that are invalid because a value has failed to
  301.      end up in a register, or has ended up in a register of the wrong
  302.      kind.  It fixes up these instructions by reloading the
  303.      problematical values temporarily into registers.  Additional
  304.      instructions are generated to do the copying.
  305.      The reload pass also optionally eliminates the frame pointer and
  306.      inserts instructions to save and restore call-clobbered registers
  307.      around calls.
  308.      Source files are `reload.c' and `reload1.c', plus the header
  309.      `reload.h' used for communication between them.
  310.      The option `-dg' causes a debugging dump of the RTL code after
  311.      this pass.  This dump file's name is made by appending `.greg' to
  312.      the input file name.
  313.    * Instruction scheduling is repeated here to try to avoid pipeline
  314.      stalls due to memory loads generated for spilled pseudo registers.
  315.      The option `-dR' causes a debugging dump of the RTL code after
  316.      this pass.  This dump file's name is made by appending `.sched2'
  317.      to the input file name.
  318.    * Jump optimization is repeated, this time including cross-jumping
  319.      and deletion of no-op move instructions.
  320.      The option `-dJ' causes a debugging dump of the RTL code after
  321.      this pass.  This dump file's name is made by appending `.jump2' to
  322.      the input file name.
  323.    * Delayed branch scheduling.  This optional pass attempts to find
  324.      instructions that can go into the delay slots of other
  325.      instructions, usually jumps and calls.  The source file name is
  326.      `reorg.c'.
  327.      The option `-dd' causes a debugging dump of the RTL code after
  328.      this pass.  This dump file's name is made by appending `.dbr' to
  329.      the input file name.
  330.    * Conversion from usage of some hard registers to usage of a register
  331.      stack may be done at this point.  Currently, this is supported only
  332.      for the floating-point registers of the Intel 80387 coprocessor.
  333.      The source file name is `reg-stack.c'.
  334.      The options `-dk' causes a debugging dump of the RTL code after
  335.      this pass.  This dump file's name is made by appending `.stack' to
  336.      the input file name.
  337.    * Final.  This pass outputs the assembler code for the function.  It
  338.      is also responsible for identifying spurious test and compare
  339.      instructions.  Machine-specific peephole optimizations are
  340.      performed at the same time.  The function entry and exit sequences
  341.      are generated directly as assembler code in this pass; they never
  342.      exist as RTL.
  343.      The source files are `final.c' plus `insn-output.c'; the latter is
  344.      generated automatically from the machine description by the tool
  345.      `genoutput'.  The header file `conditions.h' is used for
  346.      communication between these files.
  347.    * Debugging information output.  This is run after final because it
  348.      must output the stack slot offsets for pseudo registers that did
  349.      not get hard registers.  Source files are `dbxout.c' for DBX
  350.      symbol table format, `sdbout.c' for SDB symbol table format, and
  351.      `dwarfout.c' for DWARF symbol table format.
  352.    Some additional files are used by all or many passes:
  353.    * Every pass uses `machmode.def' and `machmode.h' which define the
  354.      machine modes.
  355.    * Several passes use `real.h', which defines the default
  356.      representation of floating point constants and how to operate on
  357.      them.
  358.    * All the passes that work with RTL use the header files `rtl.h' and
  359.      `rtl.def', and subroutines in file `rtl.c'.  The tools `gen*' also
  360.      use these files to read and work with the machine description RTL.
  361.    * Several passes refer to the header file `insn-config.h' which
  362.      contains a few parameters (C macro definitions) generated
  363.      automatically from the machine description RTL by the tool
  364.      `genconfig'.
  365.    * Several passes use the instruction recognizer, which consists of
  366.      `recog.c' and `recog.h', plus the files `insn-recog.c' and
  367.      `insn-extract.c' that are generated automatically from the machine
  368.      description by the tools `genrecog' and `genextract'.
  369.    * Several passes use the header files `regs.h' which defines the
  370.      information recorded about pseudo register usage, and
  371.      `basic-block.h' which defines the information recorded about basic
  372.      blocks.
  373.    * `hard-reg-set.h' defines the type `HARD_REG_SET', a bit-vector
  374.      with a bit for each hard register, and some macros to manipulate
  375.      it.  This type is just `int' if the machine has few enough hard
  376.      registers; otherwise it is an array of `int' and some of the
  377.      macros expand into loops.
  378.    * Several passes use instruction attributes.  A definition of the
  379.      attributes defined for a particular machine is in file
  380.      `insn-attr.h', which is generated from the machine description by
  381.      the program `genattr'.  The file `insn-attrtab.c' contains
  382.      subroutines to obtain the attribute values for insns.  It is
  383.      generated from the machine description by the program `genattrtab'.
  384. File: gcc.info,  Node: RTL,  Next: Machine Desc,  Prev: Passes,  Up: Top
  385. RTL Representation
  386. ******************
  387.    Most of the work of the compiler is done on an intermediate
  388. representation called register transfer language.  In this language,
  389. the instructions to be output are described, pretty much one by one, in
  390. an algebraic form that describes what the instruction does.
  391.    RTL is inspired by Lisp lists.  It has both an internal form, made
  392. up of structures that point at other structures, and a textual form
  393. that is used in the machine description and in printed debugging dumps.
  394. The textual form uses nested parentheses to indicate the pointers in
  395. the internal form.
  396. * Menu:
  397. * RTL Objects::       Expressions vs vectors vs strings vs integers.
  398. * Accessors::         Macros to access expression operands or vector elts.
  399. * Flags::             Other flags in an RTL expression.
  400. * Machine Modes::     Describing the size and format of a datum.
  401. * Constants::         Expressions with constant values.
  402. * Regs and Memory::   Expressions representing register contents or memory.
  403. * Arithmetic::        Expressions representing arithmetic on other expressions.
  404. * Comparisons::       Expressions representing comparison of expressions.
  405. * Bit Fields::        Expressions representing bitfields in memory or reg.
  406. * Conversions::       Extending, truncating, floating or fixing.
  407. * RTL Declarations::  Declaring volatility, constancy, etc.
  408. * Side Effects::      Expressions for storing in registers, etc.
  409. * Incdec::            Embedded side-effects for autoincrement addressing.
  410. * Assembler::         Representing `asm' with operands.
  411. * Insns::             Expression types for entire insns.
  412. * Calls::             RTL representation of function call insns.
  413. * Sharing::           Some expressions are unique; others *must* be copied.
  414. * Reading RTL::       Reading textual RTL from a file.
  415. File: gcc.info,  Node: RTL Objects,  Next: Accessors,  Prev: RTL,  Up: RTL
  416. RTL Object Types
  417. ================
  418.    RTL uses five kinds of objects: expressions, integers, wide integers,
  419. strings and vectors.  Expressions are the most important ones.  An RTL
  420. expression ("RTX", for short) is a C structure, but it is usually
  421. referred to with a pointer; a type that is given the typedef name `rtx'.
  422.    An integer is simply an `int'; their written form uses decimal
  423. digits.  A wide integer is an integral object whose type is
  424. `HOST_WIDE_INT' (*note Config::.); their written form uses decimal
  425. digits.
  426.    A string is a sequence of characters.  In core it is represented as a
  427. `char *' in usual C fashion, and it is written in C syntax as well.
  428. However, strings in RTL may never be null.  If you write an empty
  429. string in a machine description, it is represented in core as a null
  430. pointer rather than as a pointer to a null character.  In certain
  431. contexts, these null pointers instead of strings are valid.  Within RTL
  432. code, strings are most commonly found inside `symbol_ref' expressions,
  433. but they appear in other contexts in the RTL expressions that make up
  434. machine descriptions.
  435.    A vector contains an arbitrary number of pointers to expressions.
  436. The number of elements in the vector is explicitly present in the
  437. vector.  The written form of a vector consists of square brackets
  438. (`[...]') surrounding the elements, in sequence and with whitespace
  439. separating them.  Vectors of length zero are not created; null pointers
  440. are used instead.
  441.    Expressions are classified by "expression codes" (also called RTX
  442. codes).  The expression code is a name defined in `rtl.def', which is
  443. also (in upper case) a C enumeration constant.  The possible expression
  444. codes and their meanings are machine-independent.  The code of an RTX
  445. can be extracted with the macro `GET_CODE (X)' and altered with
  446. `PUT_CODE (X, NEWCODE)'.
  447.    The expression code determines how many operands the expression
  448. contains, and what kinds of objects they are.  In RTL, unlike Lisp, you
  449. cannot tell by looking at an operand what kind of object it is.
  450. Instead, you must know from its context--from the expression code of
  451. the containing expression.  For example, in an expression of code
  452. `subreg', the first operand is to be regarded as an expression and the
  453. second operand as an integer.  In an expression of code `plus', there
  454. are two operands, both of which are to be regarded as expressions.  In
  455. a `symbol_ref' expression, there is one operand, which is to be
  456. regarded as a string.
  457.    Expressions are written as parentheses containing the name of the
  458. expression type, its flags and machine mode if any, and then the
  459. operands of the expression (separated by spaces).
  460.    Expression code names in the `md' file are written in lower case,
  461. but when they appear in C code they are written in upper case.  In this
  462. manual, they are shown as follows: `const_int'.
  463.    In a few contexts a null pointer is valid where an expression is
  464. normally wanted.  The written form of this is `(nil)'.
  465. File: gcc.info,  Node: Accessors,  Next: Flags,  Prev: RTL Objects,  Up: RTL
  466. Access to Operands
  467. ==================
  468.    For each expression type `rtl.def' specifies the number of contained
  469. objects and their kinds, with four possibilities: `e' for expression
  470. (actually a pointer to an expression), `i' for integer, `w' for wide
  471. integer, `s' for string, and `E' for vector of expressions.  The
  472. sequence of letters for an expression code is called its "format".
  473. Thus, the format of `subreg' is `ei'.
  474.    A few other format characters are used occasionally:
  475.      `u' is equivalent to `e' except that it is printed differently in
  476.      debugging dumps.  It is used for pointers to insns.
  477.      `n' is equivalent to `i' except that it is printed differently in
  478.      debugging dumps.  It is used for the line number or code number of
  479.      a `note' insn.
  480.      `S' indicates a string which is optional.  In the RTL objects in
  481.      core, `S' is equivalent to `s', but when the object is read, from
  482.      an `md' file, the string value of this operand may be omitted.  An
  483.      omitted string is taken to be the null string.
  484.      `V' indicates a vector which is optional.  In the RTL objects in
  485.      core, `V' is equivalent to `E', but when the object is read from
  486.      an `md' file, the vector value of this operand may be omitted.  An
  487.      omitted vector is effectively the same as a vector of no elements.
  488.      `0' means a slot whose contents do not fit any normal category.
  489.      `0' slots are not printed at all in dumps, and are often used in
  490.      special ways by small parts of the compiler.
  491.    There are macros to get the number of operands, the format, and the
  492. class of an expression code:
  493. `GET_RTX_LENGTH (CODE)'
  494.      Number of operands of an RTX of code CODE.
  495. `GET_RTX_FORMAT (CODE)'
  496.      The format of an RTX of code CODE, as a C string.
  497. `GET_RTX_CLASS (CODE)'
  498.      A single character representing the type of RTX operation that code
  499.      CODE performs.
  500.      The following classes are defined:
  501.     `o'
  502.           An RTX code that represents an actual object, such as `reg' or
  503.           `mem'.  `subreg' is not in this class.
  504.     `<'
  505.           An RTX code for a comparison.  The codes in this class are
  506.           `NE', `EQ', `LE', `LT', `GE', `GT', `LEU', `LTU', `GEU',
  507.           `GTU'.
  508.     `1'
  509.           An RTX code for a unary arithmetic operation, such as `neg'.
  510.     `c'
  511.           An RTX code for a commutative binary operation, other than
  512.           `NE' and `EQ' (which have class `<').
  513.     `2'
  514.           An RTX code for a noncommutative binary operation, such as
  515.           `MINUS'.
  516.     `b'
  517.           An RTX code for a bitfield operation, either `ZERO_EXTRACT' or
  518.           `SIGN_EXTRACT'.
  519.     `3'
  520.           An RTX code for other three input operations, such as
  521.           `IF_THEN_ELSE'.
  522.     `i'
  523.           An RTX code for a machine insn (`INSN', `JUMP_INSN', and
  524.           `CALL_INSN').
  525.     `m'
  526.           An RTX code for something that matches in insns, such as
  527.           `MATCH_DUP'.
  528.     `x'
  529.           All other RTX codes.
  530.    Operands of expressions are accessed using the macros `XEXP',
  531. `XINT', `XWINT' and `XSTR'.  Each of these macros takes two arguments:
  532. an expression-pointer (RTX) and an operand number (counting from zero).
  533. Thus,
  534.      XEXP (X, 2)
  535. accesses operand 2 of expression X, as an expression.
  536.      XINT (X, 2)
  537. accesses the same operand as an integer.  `XSTR', used in the same
  538. fashion, would access it as a string.
  539.    Any operand can be accessed as an integer, as an expression or as a
  540. string.  You must choose the correct method of access for the kind of
  541. value actually stored in the operand.  You would do this based on the
  542. expression code of the containing expression.  That is also how you
  543. would know how many operands there are.
  544.    For example, if X is a `subreg' expression, you know that it has two
  545. operands which can be correctly accessed as `XEXP (X, 0)' and `XINT (X,
  546. 1)'.  If you did `XINT (X, 0)', you would get the address of the
  547. expression operand but cast as an integer; that might occasionally be
  548. useful, but it would be cleaner to write `(int) XEXP (X, 0)'.  `XEXP
  549. (X, 1)' would also compile without error, and would return the second,
  550. integer operand cast as an expression pointer, which would probably
  551. result in a crash when accessed.  Nothing stops you from writing `XEXP
  552. (X, 28)' either, but this will access memory past the end of the
  553. expression with unpredictable results.
  554.    Access to operands which are vectors is more complicated.  You can
  555. use the macro `XVEC' to get the vector-pointer itself, or the macros
  556. `XVECEXP' and `XVECLEN' to access the elements and length of a vector.
  557. `XVEC (EXP, IDX)'
  558.      Access the vector-pointer which is operand number IDX in EXP.
  559. `XVECLEN (EXP, IDX)'
  560.      Access the length (number of elements) in the vector which is in
  561.      operand number IDX in EXP.  This value is an `int'.
  562. `XVECEXP (EXP, IDX, ELTNUM)'
  563.      Access element number ELTNUM in the vector which is in operand
  564.      number IDX in EXP.  This value is an RTX.
  565.      It is up to you to make sure that ELTNUM is not negative and is
  566.      less than `XVECLEN (EXP, IDX)'.
  567.    All the macros defined in this section expand into lvalues and
  568. therefore can be used to assign the operands, lengths and vector
  569. elements as well as to access them.
  570. File: gcc.info,  Node: Flags,  Next: Machine Modes,  Prev: Accessors,  Up: RTL
  571. Flags in an RTL Expression
  572. ==========================
  573.    RTL expressions contain several flags (one-bit bitfields) that are
  574. used in certain types of expression.  Most often they are accessed with
  575. the following macros:
  576. `MEM_VOLATILE_P (X)'
  577.      In `mem' expressions, nonzero for volatile memory references.
  578.      Stored in the `volatil' field and printed as `/v'.
  579. `MEM_IN_STRUCT_P (X)'
  580.      In `mem' expressions, nonzero for reference to an entire
  581.      structure, union or array, or to a component of one.  Zero for
  582.      references to a scalar variable or through a pointer to a scalar.
  583.      Stored in the `in_struct' field and printed as `/s'.
  584. `REG_LOOP_TEST_P'
  585.      In `reg' expressions, nonzero if this register's entire life is
  586.      contained in the exit test code for some loop.  Stored in the
  587.      `in_struct' field and printed as `/s'.
  588. `REG_USERVAR_P (X)'
  589.      In a `reg', nonzero if it corresponds to a variable present in the
  590.      user's source code.  Zero for temporaries generated internally by
  591.      the compiler.  Stored in the `volatil' field and printed as `/v'.
  592. `REG_FUNCTION_VALUE_P (X)'
  593.      Nonzero in a `reg' if it is the place in which this function's
  594.      value is going to be returned.  (This happens only in a hard
  595.      register.)  Stored in the `integrated' field and printed as `/i'.
  596.      The same hard register may be used also for collecting the values
  597.      of functions called by this one, but `REG_FUNCTION_VALUE_P' is zero
  598.      in this kind of use.
  599. `SUBREG_PROMOTED_VAR_P'
  600.      Nonzero in a `subreg' if it was made when accessing an object that
  601.      was promoted to a wider mode in accord with the `PROMOTED_MODE'
  602.      machine description macro (*note Storage Layout::.).  In this
  603.      case, the mode of the `subreg' is the declared mode of the object
  604.      and the mode of `SUBREG_REG' is the mode of the register that
  605.      holds the object.  Promoted variables are always either sign- or
  606.      zero-extended to the wider mode on every assignment.  Stored in
  607.      the `in_struct' field and printed as `/s'.
  608. `SUBREG_PROMOTED_UNSIGNED_P'
  609.      Nonzero in a `subreg' that has `SUBREG_PROMOTED_VAR_P' nonzero if
  610.      the object being referenced is kept zero-extended and zero if it
  611.      is kept sign-extended.  Stored in the `unchanging' field and
  612.      printed as `/u'.
  613. `RTX_UNCHANGING_P (X)'
  614.      Nonzero in a `reg' or `mem' if the value is not changed.  (This
  615.      flag is not set for memory references via pointers to constants.
  616.      Such pointers only guarantee that the object will not be changed
  617.      explicitly by the current function.  The object might be changed by
  618.      other functions or by aliasing.)  Stored in the `unchanging' field
  619.      and printed as `/u'.
  620. `RTX_INTEGRATED_P (INSN)'
  621.      Nonzero in an insn if it resulted from an in-line function call.
  622.      Stored in the `integrated' field and printed as `/i'.  This may be
  623.      deleted; nothing currently depends on it.
  624. `SYMBOL_REF_USED (X)'
  625.      In a `symbol_ref', indicates that X has been used.  This is
  626.      normally only used to ensure that X is only declared external
  627.      once.  Stored in the `used' field.
  628. `SYMBOL_REF_FLAG (X)'
  629.      In a `symbol_ref', this is used as a flag for machine-specific
  630.      purposes.  Stored in the `volatil' field and printed as `/v'.
  631. `LABEL_OUTSIDE_LOOP_P'
  632.      In `label_ref' expressions, nonzero if this is a reference to a
  633.      label that is outside the innermost loop containing the reference
  634.      to the label.  Stored in the `in_struct' field and printed as `/s'.
  635. `INSN_DELETED_P (INSN)'
  636.      In an insn, nonzero if the insn has been deleted.  Stored in the
  637.      `volatil' field and printed as `/v'.
  638. `INSN_ANNULLED_BRANCH_P (INSN)'
  639.      In an `insn' in the delay slot of a branch insn, indicates that an
  640.      annulling branch should be used.  See the discussion under
  641.      `sequence' below.  Stored in the `unchanging' field and printed as
  642.      `/u'.
  643. `INSN_FROM_TARGET_P (INSN)'
  644.      In an `insn' in a delay slot of a branch, indicates that the insn
  645.      is from the target of the branch.  If the branch insn has
  646.      `INSN_ANNULLED_BRANCH_P' set, this insn should only be executed if
  647.      the branch is taken.  For annulled branches with this bit clear,
  648.      the insn should be executed only if the branch is not taken.
  649.      Stored in the `in_struct' field and printed as `/s'.
  650. `CONSTANT_POOL_ADDRESS_P (X)'
  651.      Nonzero in a `symbol_ref' if it refers to part of the current
  652.      function's "constants pool".  These are addresses close to the
  653.      beginning of the function, and GNU CC assumes they can be addressed
  654.      directly (perhaps with the help of base registers).  Stored in the
  655.      `unchanging' field and printed as `/u'.
  656. `CONST_CALL_P (X)'
  657.      In a `call_insn', indicates that the insn represents a call to a
  658.      const function.  Stored in the `unchanging' field and printed as
  659.      `/u'.
  660. `LABEL_PRESERVE_P (X)'
  661.      In a `code_label', indicates that the label can never be deleted.
  662.      Labels referenced by a non-local goto will have this bit set.
  663.      Stored in the `in_struct' field and printed as `/s'.
  664. `SCHED_GROUP_P (INSN)'
  665.      During instruction scheduling, in an insn, indicates that the
  666.      previous insn must be scheduled together with this insn.  This is
  667.      used to ensure that certain groups of instructions will not be
  668.      split up by the instruction scheduling pass, for example, `use'
  669.      insns before a `call_insn' may not be separated from the
  670.      `call_insn'.  Stored in the `in_struct' field and printed as `/s'.
  671.    These are the fields which the above macros refer to:
  672. `used'
  673.      Normally, this flag is used only momentarily, at the end of RTL
  674.      generation for a function, to count the number of times an
  675.      expression appears in insns.  Expressions that appear more than
  676.      once are copied, according to the rules for shared structure
  677.      (*note Sharing::.).
  678.      In a `symbol_ref', it indicates that an external declaration for
  679.      the symbol has already been written.
  680.      In a `reg', it is used by the leaf register renumbering code to
  681.      ensure that each register is only renumbered once.
  682. `volatil'
  683.      This flag is used in `mem', `symbol_ref' and `reg' expressions and
  684.      in insns.  In RTL dump files, it is printed as `/v'.
  685.      In a `mem' expression, it is 1 if the memory reference is volatile.
  686.      Volatile memory references may not be deleted, reordered or
  687.      combined.
  688.      In a `symbol_ref' expression, it is used for machine-specific
  689.      purposes.
  690.      In a `reg' expression, it is 1 if the value is a user-level
  691.      variable.  0 indicates an internal compiler temporary.
  692.      In an insn, 1 means the insn has been deleted.
  693. `in_struct'
  694.      In `mem' expressions, it is 1 if the memory datum referred to is
  695.      all or part of a structure or array; 0 if it is (or might be) a
  696.      scalar variable.  A reference through a C pointer has 0 because
  697.      the pointer might point to a scalar variable.  This information
  698.      allows the compiler to determine something about possible cases of
  699.      aliasing.
  700.      In an insn in the delay slot of a branch, 1 means that this insn
  701.      is from the target of the branch.
  702.      During instruction scheduling, in an insn, 1 means that this insn
  703.      must be scheduled as part of a group together with the previous
  704.      insn.
  705.      In `reg' expressions, it is 1 if the register has its entire life
  706.      contained within the test expression of some loop.
  707.      In `subreg' expressions, 1 means that the `subreg' is accessing an
  708.      object that has had its mode promoted from a wider mode.
  709.      In `label_ref' expressions, 1 means that the referenced label is
  710.      outside the innermost loop containing the insn in which the
  711.      `label_ref' was found.
  712.      In `code_label' expressions, it is 1 if the label may never be
  713.      deleted.  This is used for labels which are the target of
  714.      non-local gotos.
  715.      In an RTL dump, this flag is represented as `/s'.
  716. `unchanging'
  717.      In `reg' and `mem' expressions, 1 means that the value of the
  718.      expression never changes.
  719.      In `subreg' expressions, it is 1 if the `subreg' references an
  720.      unsigned object whose mode has been promoted to a wider mode.
  721.      In an insn, 1 means that this is an annulling branch.
  722.      In a `symbol_ref' expression, 1 means that this symbol addresses
  723.      something in the per-function constants pool.
  724.      In a `call_insn', 1 means that this instruction is a call to a
  725.      const function.
  726.      In an RTL dump, this flag is represented as `/u'.
  727. `integrated'
  728.      In some kinds of expressions, including insns, this flag means the
  729.      rtl was produced by procedure integration.
  730.      In a `reg' expression, this flag indicates the register containing
  731.      the value to be returned by the current function.  On machines
  732.      that pass parameters in registers, the same register number may be
  733.      used for parameters as well, but this flag is not set on such uses.
  734. File: gcc.info,  Node: Machine Modes,  Next: Constants,  Prev: Flags,  Up: RTL
  735. Machine Modes
  736. =============
  737.    A machine mode describes a size of data object and the
  738. representation used for it.  In the C code, machine modes are
  739. represented by an enumeration type, `enum machine_mode', defined in
  740. `machmode.def'.  Each RTL expression has room for a machine mode and so
  741. do certain kinds of tree expressions (declarations and types, to be
  742. precise).
  743.    In debugging dumps and machine descriptions, the machine mode of an
  744. RTL expression is written after the expression code with a colon to
  745. separate them.  The letters `mode' which appear at the end of each
  746. machine mode name are omitted.  For example, `(reg:SI 38)' is a `reg'
  747. expression with machine mode `SImode'.  If the mode is `VOIDmode', it
  748. is not written at all.
  749.    Here is a table of machine modes.  The term "byte" below refers to an
  750. object of `BITS_PER_UNIT' bits (*note Storage Layout::.).
  751. `QImode'
  752.      "Quarter-Integer" mode represents a single byte treated as an
  753.      integer.
  754. `HImode'
  755.      "Half-Integer" mode represents a two-byte integer.
  756. `PSImode'
  757.      "Partial Single Integer" mode represents an integer which occupies
  758.      four bytes but which doesn't really use all four.  On some
  759.      machines, this is the right mode to use for pointers.
  760. `SImode'
  761.      "Single Integer" mode represents a four-byte integer.
  762. `PDImode'
  763.      "Partial Double Integer" mode represents an integer which occupies
  764.      eight bytes but which doesn't really use all eight.  On some
  765.      machines, this is the right mode to use for certain pointers.
  766. `DImode'
  767.      "Double Integer" mode represents an eight-byte integer.
  768. `TImode'
  769.      "Tetra Integer" (?) mode represents a sixteen-byte integer.
  770. `SFmode'
  771.      "Single Floating" mode represents a single-precision (four byte)
  772.      floating point number.
  773. `DFmode'
  774.      "Double Floating" mode represents a double-precision (eight byte)
  775.      floating point number.
  776. `XFmode'
  777.      "Extended Floating" mode represents a triple-precision (twelve
  778.      byte) floating point number.  This mode is used for IEEE extended
  779.      floating point.  On some systems not all bits within these bytes
  780.      will actually be used.
  781. `TFmode'
  782.      "Tetra Floating" mode represents a quadruple-precision (sixteen
  783.      byte) floating point number.
  784. `CCmode'
  785.      "Condition Code" mode represents the value of a condition code,
  786.      which is a machine-specific set of bits used to represent the
  787.      result of a comparison operation.  Other machine-specific modes
  788.      may also be used for the condition code.  These modes are not used
  789.      on machines that use `cc0' (see *note Condition Code::.).
  790. `BLKmode'
  791.      "Block" mode represents values that are aggregates to which none of
  792.      the other modes apply.  In RTL, only memory references can have
  793.      this mode, and only if they appear in string-move or vector
  794.      instructions.  On machines which have no such instructions,
  795.      `BLKmode' will not appear in RTL.
  796. `VOIDmode'
  797.      Void mode means the absence of a mode or an unspecified mode.  For
  798.      example, RTL expressions of code `const_int' have mode `VOIDmode'
  799.      because they can be taken to have whatever mode the context
  800.      requires.  In debugging dumps of RTL, `VOIDmode' is expressed by
  801.      the absence of any mode.
  802. `SCmode, DCmode, XCmode, TCmode'
  803.      These modes stand for a complex number represented as a pair of
  804.      floating point values.  The floating point values are in `SFmode',
  805.      `DFmode', `XFmode', and `TFmode', respectively.
  806. `CQImode, CHImode, CSImode, CDImode, CTImode, COImode'
  807.      These modes stand for a complex number represented as a pair of
  808.      integer values.  The integer values are in `QImode', `HImode',
  809.      `SImode', `DImode', `TImode', and `OImode', respectively.
  810.    The machine description defines `Pmode' as a C macro which expands
  811. into the machine mode used for addresses.  Normally this is the mode
  812. whose size is `BITS_PER_WORD', `SImode' on 32-bit machines.
  813.    The only modes which a machine description must support are
  814. `QImode', and the modes corresponding to `BITS_PER_WORD',
  815. `FLOAT_TYPE_SIZE' and `DOUBLE_TYPE_SIZE'.  The compiler will attempt to
  816. use `DImode' for 8-byte structures and unions, but this can be
  817. prevented by overriding the definition of `MAX_FIXED_MODE_SIZE'.
  818. Alternatively, you can have the compiler use `TImode' for 16-byte
  819. structures and unions.  Likewise, you can arrange for the C type `short
  820. int' to avoid using `HImode'.
  821.    Very few explicit references to machine modes remain in the compiler
  822. and these few references will soon be removed.  Instead, the machine
  823. modes are divided into mode classes.  These are represented by the
  824. enumeration type `enum mode_class' defined in `machmode.h'.  The
  825. possible mode classes are:
  826. `MODE_INT'
  827.      Integer modes.  By default these are `QImode', `HImode', `SImode',
  828.      `DImode', and `TImode'.
  829. `MODE_PARTIAL_INT'
  830.      The "partial integer" modes, `PSImode' and `PDImode'.
  831. `MODE_FLOAT'
  832.      floating point modes.  By default these are `SFmode', `DFmode',
  833.      `XFmode' and `TFmode'.
  834. `MODE_COMPLEX_INT'
  835.      Complex integer modes.  (These are not currently implemented).
  836. `MODE_COMPLEX_FLOAT'
  837.      Complex floating point modes.  By default these are `SCmode',
  838.      `DCmode', `XCmode', and `TCmode'.
  839. `MODE_FUNCTION'
  840.      Algol or Pascal function variables including a static chain.
  841.      (These are not currently implemented).
  842. `MODE_CC'
  843.      Modes representing condition code values.  These are `CCmode' plus
  844.      any modes listed in the `EXTRA_CC_MODES' macro.  *Note Jump
  845.      Patterns::, also see *Note Condition Code::.
  846. `MODE_RANDOM'
  847.      This is a catchall mode class for modes which don't fit into the
  848.      above classes.  Currently `VOIDmode' and `BLKmode' are in
  849.      `MODE_RANDOM'.
  850.    Here are some C macros that relate to machine modes:
  851. `GET_MODE (X)'
  852.      Returns the machine mode of the RTX X.
  853. `PUT_MODE (X, NEWMODE)'
  854.      Alters the machine mode of the RTX X to be NEWMODE.
  855. `NUM_MACHINE_MODES'
  856.      Stands for the number of machine modes available on the target
  857.      machine.  This is one greater than the largest numeric value of any
  858.      machine mode.
  859. `GET_MODE_NAME (M)'
  860.      Returns the name of mode M as a string.
  861. `GET_MODE_CLASS (M)'
  862.      Returns the mode class of mode M.
  863. `GET_MODE_WIDER_MODE (M)'
  864.      Returns the next wider natural mode.  For example, the expression
  865.      `GET_MODE_WIDER_MODE (QImode)' returns `HImode'.
  866. `GET_MODE_SIZE (M)'
  867.      Returns the size in bytes of a datum of mode M.
  868. `GET_MODE_BITSIZE (M)'
  869.      Returns the size in bits of a datum of mode M.
  870. `GET_MODE_MASK (M)'
  871.      Returns a bitmask containing 1 for all bits in a word that fit
  872.      within mode M.  This macro can only be used for modes whose
  873.      bitsize is less than or equal to `HOST_BITS_PER_INT'.
  874. `GET_MODE_ALIGNMENT (M))'
  875.      Return the required alignment, in bits, for an object of mode M.
  876. `GET_MODE_UNIT_SIZE (M)'
  877.      Returns the size in bytes of the subunits of a datum of mode M.
  878.      This is the same as `GET_MODE_SIZE' except in the case of complex
  879.      modes.  For them, the unit size is the size of the real or
  880.      imaginary part.
  881. `GET_MODE_NUNITS (M)'
  882.      Returns the number of units contained in a mode, i.e.,
  883.      `GET_MODE_SIZE' divided by `GET_MODE_UNIT_SIZE'.
  884. `GET_CLASS_NARROWEST_MODE (C)'
  885.      Returns the narrowest mode in mode class C.
  886.    The global variables `byte_mode' and `word_mode' contain modes whose
  887. classes are `MODE_INT' and whose bitsizes are either `BITS_PER_UNIT' or
  888. `BITS_PER_WORD', respectively.  On 32-bit machines, these are `QImode'
  889. and `SImode', respectively.
  890.